Location: BondGraph Basic @ a8af5c258bce / BG Tutorial Mechanical Systems / Oscillating beam with spring and damper.cellml

Author:
Soroush Safaei <ssaf006@aucklanduni.ac.nz>
Date:
2017-06-18 14:33:01+12:00
Desc:
adding momentum
Permanent Source URI:
https://models.fieldml.org/workspace/43b/rawfile/a8af5c258bce90218417d3e8a42a86a4c490253d/BG Tutorial Mechanical Systems/Oscillating beam with spring and damper.cellml

<?xml version='1.0'?>
<model name="my_model" xmlns="http://www.cellml.org/cellml/1.1#" xmlns:cellml="http://www.cellml.org/cellml/1.1#">
    <!-- Your code goes here-->
    <units name="rad_per_s">
        <unit units="radian"/>
        <unit exponent="-1" units="second"/>
    </units>
    <units name="m4">
        <unit exponent="4" units="metre"/>
    </units>
    <units name="per_m">
        <unit exponent="-1" units="metre"/>
    </units>
    <units name="m_per_s">
        <unit units="metre"/>
        <unit exponent="-1" units="second"/>
    </units>
    <units name="Jm">
        <unit units="joule"/>
        <unit units="metre"/>
    </units>
    <units name="J_per_m">
        <unit units="joule"/>
        <unit exponent="-1" units="metre"/>
    </units>
    <units name="J_per_m2">
        <unit units="joule"/>
        <unit exponent="-2" units="metre"/>
    </units>
    <units name="J_per_m3">
        <unit units="joule"/>
        <unit exponent="-3" units="metre"/>
    </units>
    <units name="Js_per_m2">
        <unit units="joule"/>
        <unit units="second"/>
        <unit exponent="-2" units="metre"/>
    </units>
    <component name="main">
        <!-- Unknown is omega-->
        <variable initial_value="0" name="t" units="second"/>
        <variable initial_value="1" name="t_ref" units="second"/>
        <variable initial_value="0" name="x" units="metre"/>
        <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
                <eq/>
                <apply>
                    <diff/>
                    <bvar>
                        <ci>t</ci>
                    </bvar>
                    <ci>x</ci>
                </apply>
                <cn cellml:units="m_per_s">1</cn>
            </apply>
        </math>
        <variable initial_value="0" name="theta" units="radian"/>
        <variable name="omega" units="rad_per_s"/>
        <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
                <eq/>
                <ci>omega</ci>
                <apply>
                    <times/>
                    <cn cellml:units="rad_per_s">0.1</cn>
                    <apply>
                        <cos/>
                        <apply>
                            <divide/>
                            <ci>t</ci>
                            <ci>t_ref</ci>
                        </apply>
                    </apply>
                </apply>
            </apply>
            <apply>
                <eq/>
                <apply>
                    <diff/>
                    <bvar>
                        <ci>t</ci>
                    </bvar>
                    <ci>theta</ci>
                </apply>
                <ci>omega</ci>
            </apply>
        </math>
        <!-- Beam geometry-->
        <variable initial_value="1" name="l_AB" units="metre"/>
        <variable name="l_AB_error" units="metre"/>
        <variable initial_value="0.2" name="x_A_1" units="metre"/>
        <variable initial_value="0.2" name="x_A_2" units="metre"/>
        <variable initial_value="1.2" name="x_B_1" units="metre"/>
        <variable initial_value="0.2" name="x_B_2" units="metre"/>
        <variable name="v_B_1" units="m_per_s"/>
        <variable name="v_B_2" units="m_per_s"/>
        <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
                <eq/>
                <ci>v_B_1</ci>
                <apply>
                    <times/>
                    <apply>
                        <minus/>
                        <ci>l_AB</ci>
                    </apply>
                    <apply>
                        <sin/>
                        <ci>theta</ci>
                    </apply>
                    <ci>omega</ci>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>v_B_2</ci>
                <apply>
                    <times/>
                    <ci>l_AB</ci>
                    <apply>
                        <cos/>
                        <ci>theta</ci>
                    </apply>
                    <ci>omega</ci>
                </apply>
            </apply>
            <apply>
                <eq/>
                <apply>
                    <diff/>
                    <bvar>
                        <ci>t</ci>
                    </bvar>
                    <ci>x_B_1</ci>
                </apply>
                <ci>v_B_1</ci>
            </apply>
            <apply>
                <eq/>
                <apply>
                    <diff/>
                    <bvar>
                        <ci>t</ci>
                    </bvar>
                    <ci>x_B_2</ci>
                </apply>
                <ci>v_B_2</ci>
            </apply>
            <apply>
                <eq/>
                <ci>l_AB_error</ci>
                <apply>
                    <minus/>
                    <ci>l_AB</ci>
                    <apply>
                        <root/>
                        <apply>
                            <plus/>
                            <apply>
                                <power/>
                                <apply>
                                    <minus/>
                                    <ci>x_B_1</ci>
                                    <ci>x_A_1</ci>
                                </apply>
                                <cn cellml:units="dimensionless">2</cn>
                            </apply>
                            <apply>
                                <power/>
                                <apply>
                                    <minus/>
                                    <ci>x_B_2</ci>
                                    <ci>x_A_2</ci>
                                </apply>
                                <cn cellml:units="dimensionless">2</cn>
                            </apply>
                        </apply>
                    </apply>
                </apply>
            </apply>
        </math>
        <!-- Spring-damper geometry-->
        <variable initial_value="1.2" name="x_C_1" units="metre"/>
        <variable initial_value="1.2" name="x_C_2" units="metre"/>
        <variable initial_value="1" name="l_BC" units="metre"/>
        <variable name="l_BC_error" units="metre"/>
        <variable name="v_BC" units="m_per_s"/>
        <variable name="beta" units="radian"/>
        <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
                <eq/>
                <ci>v_BC</ci>
                <apply>
                    <divide/>
                    <apply>
                        <plus/>
                        <apply>
                            <times/>
                            <apply>
                                <minus/>
                                <ci>x_B_1</ci>
                                <ci>x_C_1</ci>
                            </apply>
                            <ci>v_B_1</ci>
                        </apply>
                        <apply>
                            <times/>
                            <apply>
                                <minus/>
                                <ci>x_B_2</ci>
                                <ci>x_C_2</ci>
                            </apply>
                            <ci>v_B_2</ci>
                        </apply>
                    </apply>
                    <ci>l_BC</ci>
                </apply>
            </apply>
            <apply>
                <eq/>
                <apply>
                    <diff/>
                    <bvar>
                        <ci>t</ci>
                    </bvar>
                    <ci>l_BC</ci>
                </apply>
                <ci>v_BC</ci>
            </apply>
            <apply>
                <eq/>
                <ci>l_BC_error</ci>
                <apply>
                    <minus/>
                    <ci>l_BC</ci>
                    <apply>
                        <root/>
                        <apply>
                            <plus/>
                            <apply>
                                <power/>
                                <apply>
                                    <minus/>
                                    <ci>x_B_1</ci>
                                    <ci>x_C_1</ci>
                                </apply>
                                <cn cellml:units="dimensionless">2</cn>
                            </apply>
                            <apply>
                                <power/>
                                <apply>
                                    <minus/>
                                    <ci>x_B_2</ci>
                                    <ci>x_C_2</ci>
                                </apply>
                                <cn cellml:units="dimensionless">2</cn>
                            </apply>
                        </apply>
                    </apply>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>beta</ci>
                <apply>
                    <arctan/>
                    <apply>
                        <divide/>
                        <apply>
                            <minus/>
                            <ci>x_B_1</ci>
                            <ci>x_C_1</ci>
                        </apply>
                        <apply>
                            <minus/>
                            <ci>x_B_2</ci>
                            <ci>x_C_2</ci>
                        </apply>
                    </apply>
                </apply>
            </apply>
        </math>
        <!-- Spring-damper equations-->
        <variable initial_value="1" name="E_1" units="J_per_m2"/>
        <variable initial_value="1" name="R_1" units="Js_per_m2"/>
        <variable name="f_C_e" units="J_per_m"/>
        <variable name="f_C_r" units="J_per_m"/>
        <variable initial_value="1" name="l_BC_0" units="metre"/>
        <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
                <eq/>
                <ci>f_C_e</ci>
                <apply>
                    <times/>
                    <ci>E_1</ci>
                    <apply>
                        <minus/>
                        <ci>l_BC</ci>
                        <ci>l_BC_0</ci>
                    </apply>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>f_C_r</ci>
                <apply>
                    <times/>
                    <ci>R_1</ci>
                    <ci>v_BC</ci>
                </apply>
            </apply>
        </math>
        <!-- Beam equations  -->
        <variable initial_value="1" name="b" units="metre"/>
        <variable initial_value="1" name="h" units="metre"/>
        <variable name="I" units="m4"/>
        <variable initial_value="1" name="E" units="J_per_m3"/>
        <variable name="EI" units="Jm"/>
        <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
                <eq/>
                <ci>I</ci>
                <apply>
                    <divide/>
                    <apply>
                        <times/>
                        <ci>b</ci>
                        <apply>
                            <power/>
                            <ci>h</ci>
                            <cn cellml:units="dimensionless">3</cn>
                        </apply>
                    </apply>
                    <cn cellml:units="dimensionless">12</cn>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>EI</ci>
                <apply>
                    <times/>
                    <ci>E</ci>
                    <ci>I</ci>
                </apply>
            </apply>
        </math>
        <variable initial_value="1" name="n" units="dimensionless"/>
        <variable name="f_A_n" units="J_per_m"/>
        <variable name="f_B_n" units="J_per_m"/>
        <variable initial_value="1" name="a_n" units="metre"/>
        <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
                <eq/>
                <ci>f_A_n</ci>
                <apply>
                    <times/>
                    <apply>
                        <minus/>
                        <apply>
                            <power/>
                            <apply>
                                <divide/>
                                <apply>
                                    <times/>
                                    <ci>n</ci>
                                    <pi/>
                                </apply>
                                <ci>l_AB</ci>
                            </apply>
                            <cn cellml:units="dimensionless">3</cn>
                        </apply>
                    </apply>
                    <ci>EI</ci>
                    <ci>a_n</ci>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>f_B_n</ci>
                <apply>
                    <times/>
                    <apply>
                        <power/>
                        <apply>
                            <minus/>
                            <cn cellml:units="dimensionless">1</cn>
                        </apply>
                        <apply>
                            <plus/>
                            <ci>n</ci>
                            <cn cellml:units="dimensionless">1</cn>
                        </apply>
                    </apply>
                    <apply>
                        <power/>
                        <apply>
                            <divide/>
                            <apply>
                                <times/>
                                <ci>n</ci>
                                <pi/>
                            </apply>
                            <ci>l_AB</ci>
                        </apply>
                        <cn cellml:units="dimensionless">3</cn>
                    </apply>
                    <ci>EI</ci>
                    <ci>a_n</ci>
                </apply>
            </apply>
        </math>
        <!-- BG equations-->
        <variable name="u_A_x1" units="J_per_m"/>
        <variable name="u_A_x2" units="J_per_m"/>
        <variable name="u_B_x1" units="J_per_m"/>
        <variable name="u_B_x2" units="J_per_m"/>
        <variable name="u_C_x1" units="J_per_m"/>
        <variable name="u_C_x2" units="J_per_m"/>
        <variable name="u_tot_x1" units="J_per_m"/>
        <variable name="u_tot_x2" units="J_per_m"/>
        <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
                <eq/>
                <ci>u_A_x1</ci>
                <apply>
                    <times/>
                    <apply>
                        <minus/>
                        <ci>f_A_n</ci>
                    </apply>
                    <apply>
                        <sin/>
                        <ci>theta</ci>
                    </apply>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>u_A_x2</ci>
                <apply>
                    <times/>
                    <ci>f_A_n</ci>
                    <apply>
                        <cos/>
                        <ci>theta</ci>
                    </apply>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>u_B_x1</ci>
                <apply>
                    <plus/>
                    <apply>
                        <times/>
                        <apply>
                            <minus/>
                            <ci>f_B_n</ci>
                        </apply>
                        <apply>
                            <sin/>
                            <ci>theta</ci>
                        </apply>
                    </apply>
                    <apply>
                        <times/>
                        <apply>
                            <plus/>
                            <ci>f_C_e</ci>
                            <ci>f_C_r</ci>
                        </apply>
                        <apply>
                            <sin/>
                            <ci>beta</ci>
                        </apply>
                    </apply>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>u_B_x2</ci>
                <apply>
                    <plus/>
                    <apply>
                        <times/>
                        <ci>f_B_n</ci>
                        <apply>
                            <cos/>
                            <ci>theta</ci>
                        </apply>
                    </apply>
                    <apply>
                        <times/>
                        <apply>
                            <plus/>
                            <ci>f_C_e</ci>
                            <ci>f_C_r</ci>
                        </apply>
                        <apply>
                            <cos/>
                            <ci>beta</ci>
                        </apply>
                    </apply>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>u_C_x1</ci>
                <apply>
                    <times/>
                    <apply>
                        <plus/>
                        <ci>f_C_e</ci>
                        <ci>f_C_r</ci>
                    </apply>
                    <apply>
                        <sin/>
                        <ci>beta</ci>
                    </apply>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>u_C_x2</ci>
                <apply>
                    <times/>
                    <apply>
                        <plus/>
                        <ci>f_C_e</ci>
                        <ci>f_C_r</ci>
                    </apply>
                    <apply>
                        <cos/>
                        <ci>beta</ci>
                    </apply>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>u_tot_x1</ci>
                <apply>
                    <plus/>
                    <ci>u_A_x1</ci>
                    <ci>u_B_x1</ci>
                    <ci>u_C_x1</ci>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>u_tot_x2</ci>
                <apply>
                    <plus/>
                    <ci>u_A_x2</ci>
                    <ci>u_B_x2</ci>
                    <ci>u_C_x2</ci>
                </apply>
            </apply>
        </math>
    </component>
</model>